{include file="index/header"}
<body>
<div class="fly-panel fly-panel-user">
  <div class="tpt-admin">
    <fieldset class="layui-elem-field layui-field-title">
      <legend>添加菜单</legend>
    </fieldset>
    <form class="layui-form">
      <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
          <input type="text" name="name" required lay-verify="required" placeholder="必填内容" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item" style="width: 300px;">
        <label class="layui-form-label">所属菜单</label>
        <div class="layui-input-block">
          <select name="pid">
            <option value="0">顶级菜单</option>
            {volist name="NavList" id="vo"}
      	    <option value="{$vo.id}">{if condition="$vo['pid'] eq 0"}{$vo.name}{/if}</option>
      	    {/volist}
          </select>
        </div>
      </div>
      <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">链接</label>
        <div class="layui-input-block">
           <input type="text" name="links" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">调用标识</label>
        <div class="layui-input-block">
           <input type="text" name="identity" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
      </div> 
      <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">别名</label>
        <div class="layui-input-block">
           <input type="text" name="alias" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
      </div>                  
      <div class="layui-form-item">
        <label class="layui-form-label">所属类型</label>
        <div class="layui-input-block">
          <input type="radio" name="type" value="1" title="PC站" checked="">
          <input type="radio" name="type" value="2" title="WAP站">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">菜单图片</label>
        <div class="layui-input-block">
      	  <input type="file" name="file" class="layui-upload-file" id="image" style="float: left;">
      	  <input type="text" name="pic" class="layui-input" style="position: absolute;left: 111px;top: 0px;width: 500px;">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">打开方式</label>
        <div class="layui-input-block">
          <input type="radio" name="target" value="0" title="现窗口打开" checked="">
          <input type="radio" name="target" value="1" title="新窗口打开">
        </div>
      </div>      
      <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
    	    <input type="text" name="sort" value="999" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-input-block">
    	  <button class="layui-btn" lay-submit="" lay-filter="nav_add">立即提交</button>
          <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
        </div>
      </div>
    </form>
  </div>
</div>
{include file="index_footer"}
<script type="text/javascript">
layui.use(['form', 'upload'],function(){
  var form = layui.form()
  ,jq = layui.jquery;
  
  layui.upload({
    url: '{:url("upload/upimage")}'
    ,elem:'#image'
    ,before: function(input){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
    }
    ,success: function(res){
      layer.close(loading);
      jq('input[name=pic]').val(res.path);
      layer.msg(res.msg, {icon: 1, time: 1000});
    }
  }); 
  
  form.on('submit(nav_add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("nav/add")}',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.href = '{:url("nav/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
</script>
</body>
</html>